package com.jf3q.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jf3q.admin.service.EduTeacherService;
import com.jf3q.common.constant.SysConstant;
import com.jf3q.common.domain.EduTeacher;
import com.jf3q.common.mapper.EduTeacherMapper;
import com.jf3q.common.vo.SearchTeacherVo;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

/**
 *
 */
@Service
public class EduTeacherServiceImpl extends ServiceImpl<EduTeacherMapper, EduTeacher>
    implements EduTeacherService {

    @Override
    public Page<EduTeacher> getPage(Integer pageNum, SearchTeacherVo searchTeacherVo) {

        Page<EduTeacher> page= new Page<>(pageNum, SysConstant.servicePageSize);
        QueryWrapper<EduTeacher> queryWrapper= new QueryWrapper();
        queryWrapper.orderByDesc("edu_modified");
        queryWrapper.eq("is_deleted",0);

        if (!ObjectUtils.isEmpty(searchTeacherVo.getName())) {
            queryWrapper.like("name",searchTeacherVo.getName());
        }
        if (!ObjectUtils.isEmpty(searchTeacherVo.getLevel())) {
            queryWrapper.eq("level",searchTeacherVo.getLevel());
        }
        if (!ObjectUtils.isEmpty(searchTeacherVo.getListDate())) {
            queryWrapper.between("edu_create",searchTeacherVo.getListDate().get(0),searchTeacherVo.getListDate().get(1));
        }

        Page<EduTeacher> iPage = baseMapper.selectPage(page, queryWrapper);
        return iPage;
    }


}




